<?php
include $this->Render('header.php');
?>
<link rel="stylesheet" type="text/css" href="<?php echo BASE_STYLE;?>/css/admin.css" />
<script type="text/javascript" src="<?php echo BASE_STYLE;?>/js/dyhl.linkpage.js"></script>
<script type="text/javascript" src="<?php echo BASE_STYLE;?>/js/common.js"></script>

<div class="tongrong-box" style="width:450px;">
	<form class="login-box-form J-ajaxForm" action="<?php echo $this->id > 0 ? '/dealers/update/option/save/' : '/dealers/save/option/save/';?>" method="post" autocomplete="off">
	<div class="tongrong-box-main">
    	<table width="100%" cellpadding="0" cellspacing="0" border="0">
        	<tr>
            	<td width="90px" height="30">经销商名称：</td>
                <td>
                	<input name="dl_name" type="text" id="dl_name" style="width:300px;" value="<?php echo $this->data['dl_name'];?>" />
                </td>
            </tr>
            <tr>
            	<td height="30">经销商简称：</td>
                <td>
                	<input name="dl_abb" type="text" id="dl_abb" style="width:300px;" value="<?php echo $this->data['dl_abb'];?>" />
                </td>
            </tr>
            <tr>
            	<td height="30">经销商电话：</td>
                <td>
                	<input name="dl_tel" type="text" id="dl_tel" style="width:300px;"  value="<?php echo $this->data['dl_tel'];?>" />
                </td>
            </tr>
            <tr>
            	<td height="30">所属网点：</td>
                <td>
               	  <select name="dl_brid" id="dl_brid">
           	      	<?php
						if(!empty($this->branch)) foreach($this->branch as $k => $v){
							$select = $v['br_id'] == $this->data['dl_brid'] ? ' selected="selected"' : '';
							echo '<option value="'.$v['br_id'].'"'.$select.'>'.$v['br_name'].'</option>';
						}
					?>
				  </select>
				</td>
            </tr>
            
        </table>
    </div>
    <div class="luru-box-btn mt30">
		<input type="hidden" name="option" value="save" />
		<input type="hidden" name="id" value="<?php echo $this->id;?>" />
    	<input class="btn-submit-blue fn-left mr15 J-submit" type="submit" value="提交" />
        <a class="a-btn-close J-a-btn-close" href="javascript:;">关闭</a>
    </div>
	</form>
</div>

<script>
	//关闭弹出
	$(".J-a-btn-close").on('click',function(){
		var winElement = parent.Ext.fly(window.frameElement).up('div.x-window');
		parent.Ext.getCmp(winElement.id).close();
	});
	
	$(document).ready(function(e) {
        $(".J-submit").on('click',function(){
			$(this).dyhlForm({
				beforefunction:submitChk,
				nofunction:function(){
					$(".J-submit").prop('disabled',false);
				},
				sucessfunction:function(data){
					$(".J-submit").prop('disabled',false);
					if(data['success']){
						Ext.Msg.alert('提示','提交成功',function(){
							window.parent.App.store.reload();
							var winElement = parent.Ext.fly(window.frameElement).up('div.x-window');
							parent.Ext.getCmp(winElement.id).close();
						});
					}else{
						Ext.Msg.alert('提示',data['msg']);
					}
				}	
			});	
		});
    });
	
	//表单验证
	function submitChk(){
		if($("#dl_name").val() == ''){
			Ext.Msg.alert('提示','经销商名称不能为空!');	
			return false;
		}
		
		$(".J-submit").prop('disabled',true);
			
	}
	
</script>

<?php include $this->Render('footer.php'); ?>